package com.taobao.auth.controller;


import com.taobao.ucenter.model.dto.AuthParamsDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
public class LoginController {

//    @Autowired
//    UserMapper userMapper;



    @RequestMapping("/login-success")
    public String loginSuccess() {

        return "登录成功";
    }

    // 测试
    @PostMapping("/test")
    public String test(@RequestBody AuthParamsDto authParamsDto) {

        System.out.println(authParamsDto);

        return "test";
    }

    @RequestMapping("/r/r1")
    @PreAuthorize("hasAuthority('p1')")//拥有p1权限方可访问
    public String r1() {
        return "访问r1资源";
    }

    @RequestMapping("/r/r2")
    @PreAuthorize("hasAuthority('p2')")//拥有p2权限方可访问
    public String r2() {
        return "访问r2资源";
    }


}
